﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="WorkFlow_WFDesigner_JobTemplateEdit"  ValidateRequest="false" Codebehind="JobTemplateEdit.aspx.cs" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>编辑流程属性</title>
    <base target="_self" />
       <meta http-equiv="Pragma" content="no-cache" />
       <meta http-equiv="Cache-Control" content="no-cache"/>
       <meta http-equiv="Expires" content="0"/> 
    <link href="../css/tab/tab.css" rel="stylesheet" type="text/css" />
    <script language="javascript" type="text/javascript" src="../css/tab/tab.js"></script>
    <script language="javascript" type="text/javascript" src="../js/WFWinCtrlScript.js"></script>
    <script language="javascript" type="text/javascript" src="../js/GridCheckBox.js"></script>
    <link href="../Styles/control.css" rel="stylesheet" type="text/css" />
</head>
<body style="margin:5px">
    <form id="form1" runat="server">    
      <div class="page_margin"> 
  <div class="nTab_l">

    <div class="TabTitle_l">
      <ul id="myTab_l">     
        <li id='li0' class="active" onclick="nTabs(this,0);">基本信息</li>
        <li id='li1' class="normal" onclick="nTabs(this,1);">流程变量</li> 
        <li id='li2' class="normal" onclick="nTabs(this,2);">流程管理员</li> 
        </ul>
    </div>

    <div class="TabContent_l" style="height:320px;overflow-y:hidden">  
    
    <div id="myTab_l_Content0" >
    <table width="100%" style="margin:5px" border='1' cellpadding="1" cellspacing="1" class="tEdit">
        <tr>
            <td class="title1">
                模板名称：</td>
            <td colspan="3">
                <asp:TextBox ID="txtName" runat="server" Width="98%" CssClass="input2"></asp:TextBox></td>
        </tr>
        <tr style="display:none">
            <td class="title1">
                模板类型：</td>
            <td colspan="3">
                <asp:RadioButtonList ID="rblTemplateType" runat="server" RepeatLayout="Flow">
                </asp:RadioButtonList></td>
        </tr>
        <tr>
            <td class="title1">
                模板状态：</td>
            <td colspan="3">
                <asp:DropDownList ID="ddlStatus" runat="server" Width="98%"  CssClass="input2">
                </asp:DropDownList></td>
        </tr>
        <tr>
            <td class="title1">
                意见列表：</td>
            <td colspan="3">
                <asp:CheckBox ID="chkIsDispUnTransactAct" runat="server" Text="显示未处理的活动环节及许可处理者" /></td>
        </tr>
        <tr>
            <td class="title1">
                模板描述：</td>
            <td colspan="3">
                <asp:TextBox ID="txtDescription" runat="server" Rows="8" TextMode="MultiLine" Width="98%"  CssClass="input2"></asp:TextBox></td>
        </tr>
        <tr>
            <td  class="title1">
                创建时间：</td>
            <td >
                <asp:Label ID="lblCreatedTime" runat="server" Text="Label"></asp:Label></td>
            <td  class="title1">
                创建人：</td>
            <td >
                <asp:Label ID="lblCreater" runat="server" Text="Label"></asp:Label></td>
        </tr>
        <tr>
            <td  class="title1">
                修改时间：</td>
            <td>
                <asp:Label ID="lblUpdatedTime" runat="server" Text="Label"></asp:Label></td>
            <td class="title1">
                版本号：</td>
            <td>
                <asp:TextBox ID="txtVersion" runat="server" Text="" Width="96%"  CssClass="input2"></asp:TextBox></td>
        </tr>
    </table>
    
    </div>
    
    <div id="myTab_l_Content1" class="none" style="height:320;overflow-y:hidden" align="center" >
        <table width="100%"  border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td><div align="right" > 
      <asp:Button ID="btnAddJobVar" Text="新增" runat="server" OnClientClick="return AddJobVar();" OnClick="btnAddJobVar_Click" class="btn_normal" 
                onmouseover="this.className='btn_active'" 
                onmouseout="this.className='btn_normal'" />
      <asp:Button ID="btnDelJobVar" Text="删除"  runat="server" OnClientClick="return mCanDelete('chkID','没有要删除的记录！');" OnClick="btnDelJobVar_Click" class="btn_normal" 
                onmouseover="this.className='btn_active'" 
                onmouseout="this.className='btn_normal'" />
      
    </div></td>
  </tr>
</table>    
            <table width="100%"  border="1" cellspacing="0" cellpadding="1" class="t1" id="tGrid">
 <thead>  
    <th style="width:30px" align="center" >
        <input type="checkbox" name="chkAll" value="checkbox" onclick='javascript:mCheckAll(this,"chkID")' />
    </th>	
	<th  align="center">变量名称</th>	
	<th  align="center">数据类型</th>	
	<th  align="center">初始值</th>	
	<th style="width:40px" align="center">操作</th>
  </thead>
  <asp:Repeater ID="repWF_JobVar" runat="server" >
  <ItemTemplate>
  <tr>
<td align="center" >
        <input type="checkbox" name="chkID" id='chk<%# DataBinder.Eval(Container.DataItem,"ID") %>'  value='<%# DataBinder.Eval(Container.DataItem,"ID") %>' >
    </td>
	<td align="left"><%# DataBinder.Eval(Container.DataItem, "Name")%></td>
	<td align="left"><%# Honestysoft.Workflow.Model.WFPublicFun.GetEnumText(typeof(Honestysoft.Workflow.Model.WFEnumData.DataType), DataBinder.Eval(Container.DataItem, "DataType")+"")%></td>	
	<td align="left"><%# DataBinder.Eval(Container.DataItem, "IniValue")%></td>
	
<td align="center">
    <%# Honestysoft.Workflow.Client.WebUI.ScriptHelper.LinkButton.GetGridDeleteButton(DataBinder.Eval(Container.DataItem, "ID") + "", btnDelJobVar.ClientID) %>
</td>
  </tr>  
  </ItemTemplate>
  </asp:Repeater>
</table>
               <input type="hidden" runat="server" id="hiVar" />
        </div>
     
    <div id="myTab_l_Content2" class="none" style="height:320;overflow-y:hidden" align="center" >
        <table width="100%"  border="0" cellspacing="0" cellpadding="5">
  <tr>
    <td><div align="right" > 
      <asp:Button ID="btnAddSpecial" Text="新增" runat="server" OnClientClick="return SelectEmployee();" OnClick="btnAddSpecial_Click"  class="btn_normal" 
                onmouseover="this.className='btn_active'" 
                onmouseout="this.className='btn_normal'" />
      <asp:Button ID="btnDelSpecial" Text="删除"  runat="server" OnClientClick="return mCanDelete('chkIDSpecial','没有要删除的记录！');" OnClick="btnDelSpecial_Click"  class="btn_normal" 
                onmouseover="this.className='btn_active'" 
                onmouseout="this.className='btn_normal'" />            
    </div></td>
  </tr>
</table>    
            <table width="100%"  border="1" cellspacing="0" cellpadding="1" class="t1" id="Table1">
 <thead>  
    <th style="width:30px" align="center" >
        <input type="checkbox" name="chkAllSpecial" value="checkbox" onclick='javascript:mCheckAll(this,"chkIDSpecial")' />
    </th>	
	<th  align="center">名称</th>	
	<th  align="center">类型</th>
	<th style="width:40px" align="center">操作</th>
  </thead>
  <asp:Repeater ID="RepSpecial" runat="server" >
  <ItemTemplate>
  <tr>
<td align="center" >
        <input type="checkbox" name="chkIDSpecial" id='chk<%# DataBinder.Eval(Container.DataItem,"ID") %>'  value='<%# DataBinder.Eval(Container.DataItem,"ID") %>' >
    </td>
	<td align="left"><%# DataBinder.Eval(Container.DataItem, "TransactorName")%></td>
	<td align="left"><%# Honestysoft.Workflow.Model.WFPublicFun.GetEnumText(typeof(Honestysoft.Workflow.Model.WFEnumData.RoleType), DataBinder.Eval(Container.DataItem, "TransactorType") + "")%></td>	
	
<td align="center">
 <%# Honestysoft.Workflow.Client.WebUI.ScriptHelper.LinkButton.GetGridDeleteButton(DataBinder.Eval(Container.DataItem, "ID") + "", btnDelSpecial.ClientID)%>
</td>
  </tr>  
  </ItemTemplate>
  </asp:Repeater>
</table>
               <asp:HiddenField ID="hiEmployees" runat="server" />
                <asp:HiddenField ID="hiRoles" runat="server" />
                <asp:HiddenField ID="hiPositions" runat="server" />
        </div>
    </div>
</div> 
</div>     
    <table width="96%" style="margin:5px" >
            <tr>
            <td align="center">
            <asp:Button ID="btnSave" Text="保存" runat="server" OnClick="btnSave_Click" class="btn_normal" 
                onmouseover="this.className='btn_active'" 
                onmouseout="this.className='btn_normal'" />
            <asp:Button ID="btnExit" Text = "退出" runat="server" OnClientClick="window.close();" class="btn_normal" 
                onmouseover="this.className='btn_active'" 
                onmouseout="this.className='btn_normal'" />
            </td>
            </tr>
    </table>
    
    </form>
    <script language="javascript" type="text/javascript">
    function AddJobVar()
      {
            var IDStr = document.getElementById("<%=hiVar.ClientID %>").value;
            var Url ="<%= WorkflowApply.Home %>WorkFlow/WFDesigner/VarEdit.aspx?Type=<%=((int)Honestysoft.Workflow.Model.WFEnumData.VarArea.JobTemplate).ToString() %>&IDStr="+IDStr;
            return mOpenDlg3(Url,600,300,"<%=WorkflowApply.Home%>","新增流程变量");
      }
 function OrgData(){
    var Type;
    var ID;
    var Name;
}
function GetOrgSelected(){               
    var EmployeeStr = document.getElementById("<%=hiEmployees.ClientID %>").value;
    var RoleStr = document.getElementById("<%=hiRoles.ClientID %>").value;
    var PositionStr = document.getElementById("<%=hiPositions.ClientID %>").value;
    var EmployeeArr;
    if(EmployeeStr != ""){
        EmployeeArr = EmployeeStr.split(",");
    }
    var RoleArr;
    if(RoleStr!=""){
        RoleArr= RoleStr.split(",");
    }    
    var PositionArr;
    if(PositionStr != ""){
        PositionArr = PositionStr.split(",");
    }
    var iArrLength=0;
    if(EmployeeArr != null){iArrLength+=EmployeeArr.length;}
    if(RoleArr != null){iArrLength+=RoleArr.length;}
    if(PositionArr != null){iArrLength+=PositionArr.length;}
    var myOrgDatas;
    if(iArrLength != 0){
     myOrgDatas = new Array(iArrLength);
    }
    if(myOrgDatas != null){
        var arrIndex=0;
        if(EmployeeArr != null){
            for(var i=0;i<EmployeeArr.length;i++){            
                var myEmployee=new OrgData();
                myEmployee.Type="Employee";
                myEmployee.ID=EmployeeArr[i].split("|")[0];
                myEmployee.Name=EmployeeArr[i].split("|")[1];
                myOrgDatas[arrIndex]=myEmployee;
                arrIndex++;
            }
        }
        if(RoleArr != null){
            for(var i=0;i<RoleArr.length;i++){            
                var myRole=new OrgData();
                myRole.Type="Role";
                myRole.ID=RoleArr[i].split("|")[0];
                myRole.Name=RoleArr[i].split("|")[1];
                myOrgDatas[arrIndex]=myRole;
                arrIndex++;
            }
        }
        if(PositionArr != null){
            for(var i=0;i<PositionArr.length;i++){            
                var myPosition=new OrgData();
                myPosition.Type="Position";
                myPosition.ID=PositionArr[i].split("|")[0];
                myPosition.Name=PositionArr[i].split("|")[1];
                myOrgDatas[arrIndex]=myPosition;
                arrIndex++;
            }
        }
    }
    return myOrgDatas;
}
function SelectEmployee()
{    
    var myOrgDatas = GetOrgSelected();
    var Url =  "<%= WorkflowApply.Home %>WorkFlow/OrgMapping/SelectOrg.aspx";
    var retValue = window.showModalDialog(Url,myOrgDatas,'dialogHeight=500px;dialogWidth=600px;help=no;scrollbars=no;status=no');    
    if(retValue != null)
    {        
        var EmployeeStr="";
        var RoleStr="";
        var PositionStr="";
        for(var i=0;i<retValue.length;i++){            
            if(retValue[i].Type=="Employee"){
                if(retValue[i].ID!=null &&(retValue[i].ID+"")!=""){
                    if(EmployeeStr==""){
                        EmployeeStr = retValue[i].ID+"|"+retValue[i].Name;
                    }        
                    else{
                        EmployeeStr +=","+ retValue[i].ID+"|"+retValue[i].Name;
                    }
                }
            }
            else if(retValue[i].Type=="Role"){
                if(retValue[i].ID!=null &&(retValue[i].ID+"")!=""){
                    if(RoleStr==""){
                        RoleStr = retValue[i].ID+"|"+retValue[i].Name;
                    }        
                    else{
                        RoleStr +=","+ retValue[i].ID+"|"+retValue[i].Name;
                    }
                }
            }
            else if(retValue[i].Type=="Position"){
                if(retValue[i].ID!=null &&(retValue[i].ID+"")!=""){
                    if(PositionStr==""){
                        PositionStr = retValue[i].ID+"|"+retValue[i].Name;
                    }        
                    else{
                        PositionStr +=","+ retValue[i].ID+"|"+retValue[i].Name;
                    }
                }
            }
        }
        document.getElementById("<%=hiEmployees.ClientID %>").value=EmployeeStr;
        document.getElementById("<%=hiRoles.ClientID %>").value=RoleStr;
        document.getElementById("<%=hiPositions.ClientID %>").value=PositionStr;
        return true;
    }
    else
    {
        return false;
    }
}
    </script>
</body>
</html>
